﻿using System;
using System.Runtime.Serialization;

namespace OpenComposite.HumanActivity.Contracts
{
	[DataContract(Namespace = "http://www.OpenComposite.com/humanactivity/faults")]
	public class HumanActivityFault
	{
		#region Initialization
		public HumanActivityFault()
			: this(null, -1, -1, null)
		{
		}
		public HumanActivityFault(string faultSource, Exception ex)
			: this(faultSource, -1, -1, ex.ToString())
		{
		}
		public HumanActivityFault(string faultSource, int activityId, int userId, string details)
		{
			this.FaultSource = faultSource;

			this.ActivityID = activityId;
			this.UserID = userId;

			this.Details = details;
		}
		#endregion

		#region Data Members
		[DataMember]
		public string FaultSource { get; set; }
		[DataMember]
		public int ActivityID { get; set; }
		[DataMember]
		public int UserID { get; set; }
		[DataMember]
		public string Details { get; set; }
		#endregion

		#region ToString
		public override string ToString()
		{
			return string.Format(
				"{0} Fault: ActivityID={1}, UserID={2};{4}(Details:{3})",
				this.FaultSource,
				this.ActivityID,
				this.UserID,
				this.Details,
				Environment.NewLine);
		}
		#endregion
	}
}
